package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.FileManagerDao;
import io.renren.entity.FileManagerEntity;
import io.renren.modules.sys.service.FileManagerService;


@Service("fileManagerService")
public class FileManagerServiceImpl extends ServiceImpl<FileManagerDao, FileManagerEntity> implements FileManagerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<FileManagerEntity> page = this.selectPage(
                new Query<FileManagerEntity>(params).getPage(),
                new EntityWrapper<FileManagerEntity>()
                        .eq("record_id",params.get("recordId"))
                        .eq("attach_type",params.get("attachType"))
                        .eq("deleted",false)
        );
        return new PageUtils(page);
    }

    @Override
    public List<FileManagerEntity> queryList(Map<String, Object> params) {
        return super.selectList(new EntityWrapper<FileManagerEntity>()
                        .eq("record_id",params.get("recordId"))
                        .eq("attach_type",params.get("attachType"))
                        .eq("deleted",false));
    }
}
